

function addSensorbitCod(Blockly) {





    //雨滴传感器模块
  Blockly.Python.microbit_rain = function(block) {
    var dropdown_rainDigital = this.getFieldValue('rainDigital');
    var dropdown_raineAnalog = this.getFieldValue('rainAnalog');
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_water'] = 'from sensor import water';
    Blockly.Python.definitions_['import_rainDigital'] = 'rainDigitalPort = '+dropdown_rainDigital;
    Blockly.Python.definitions_['import_rainAnalog'] = 'rainAnalogPort = '+dropdown_raineAnalog;
    return ''; 
  }

  //获取雨滴的模拟值
  Blockly.Python.microbit_rainAnalog = function(block) {
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_water'] = 'from sensor import water';
    var dropdown_raineAnalog = this.getFieldValue('rainAnalog');
    Blockly.Python.definitions_['import_rainAnalog' + dropdown_raineAnalog] = 'rainAnalogPort' + dropdown_raineAnalog + ' = '+dropdown_raineAnalog;
    var code = "water.get_value(rainAnalogPort" + dropdown_raineAnalog + ")";
    return [code];
  }

  //  获取雨滴的数字值
  Blockly.Python.microbit_rainDigital = function(block) {
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_water'] = 'from sensor import water';
    var dropdown_rainDigital = this.getFieldValue('rainDigital');
    Blockly.Python.definitions_['import_rainDigital' + dropdown_rainDigital] = 'rainDigitalPort' + dropdown_rainDigital + ' = '+dropdown_rainDigital;
    var code = "water.is_droplets(rainDigitalPort" + dropdown_rainDigital + ")";
    return [code];
  }
    return Blockly;
}

module.exports = addSensorbitCod;

